package com.liankuan.console.controller.vo;

import com.liankuan.console.dto.Exchange;
import lombok.Data;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

@Data
public class AddExchangeVO {
    private Integer id;
    private String publicKey;
    private String privateKey;
    private String name;
    private String alias;
    private List<String> coinPairs;

    public AddExchangeVO() {
    }

    public AddExchangeVO(Exchange exchange) {
        this.id = exchange.getId();
        this.alias = exchange.getAlias();
        this.name = exchange.getName();
        this.privateKey = exchange.getPrivateKey();
        this.publicKey = exchange.getPublicKey();
        this.coinPairs=getPairs(exchange.getCoinPairs());
    }

    private List<String> getPairs(String pairs) {
        return Arrays.stream(pairs.split(",")).collect(Collectors.toList());
    }
}
